Crate bulwark_wasm_sdk

Source
Expand description

This crate provides the logic for Bulwark’s guest environment.

Macros§

value
Construct a serde_json::Value from a JSON literal.

Structs§

BodyChunk
The first chunk of an HTTP body.
Decision
A Decision represents evidence in favor of either accepting or restricting an operation under consideration.
Extensions
A type map of protocol extensions.
Map
Represents a JSON key/value type.
Method
The Request Method (VERB)
StatusCode
An HTTP status code (status-code in RFC 7230 et al.).
Uri
The URI component of a request.
Version
Represents a version of the HTTP spec.

Enums§

BreakerDelta
The number of successes or failures to increment the breaker by.
EnvVarError
Returned when there is an issue with the environment variable requested by the plugin.
HttpError
Returned when there is an issue with an http request sent by the plugin.
Outcome
Represents a value from a continuous range taken from the pignistic transformation as a category that can be used to select a response to an operation.
ParamError
Returned when there was an issue getting or setting a parameter.
ParseCounterError
Returned when an attempt to parse a counter within a plugin environment fails.
RemoteStateError
Returned when there is an issue with the remote state requested by the plugin.
ThresholdError
Returned when a threshold is either out-of-order or out-of-range.
Value
Represents any valid JSON value.

Constants§

ACCEPT
A decision representing acceptance with full certainty.
NO_BODY
An empty HTTP body
RESTRICT
A decision representing restriction with full certainty.
UNAVAILABLE_BODY
An unavailable HTTP body
UNKNOWN
A decision representing full uncertainty.

Functions§

append_tags
Records additional tags the plugin wants to associate with its decision.
check_breaker
Checks a circuit breaker, returning the generation count, success count, failure count, consecutive success count, consecutive failure count, and expiration time.
check_rate_limit
Checks a rate limit, returning the number of attempts so far and the expiration time.
get_client_ip
Returns the originating client’s IP address, if available.
get_combined_decision
Returns the combined decision, if available.
get_combined_tags
Returns the combined set of tags associated with a decision, if available.
get_config
Returns the guest environment’s configuration value as a JSON Value.
get_config_value
Returns a named guest environment configuration value as a JSON Value.
get_env
Returns a named environment variable value as a String.
get_env_bytes
Returns a named environment variable value as bytes.
get_outcome
Returns the outcome of the combined decision, if available.
get_param_value
Returns a named value from the request context’s params.
get_remote_state
Returns the named state value retrieved from Redis.
get_request
Returns the incoming request.
get_response
Returns the response received from the interior service.
increment_breaker
Increments a circuit breaker, returning the generation count, success count, failure count, consecutive success count, consecutive failure count, and expiration time.
increment_rate_limit
Increments a rate limit, returning the number of attempts so far and the expiration time.
increment_remote_state
Increments a named counter in Redis.
increment_remote_state_by
Increments a named counter in Redis by a specified delta value.
parse_counter
Parses a counter value from state stored as a string.
receive_request_body
Determines whether the on_request_body_decision handler will be called with a request body or not.
receive_response_body
Determines whether the on_response_body_decision handler will be called with a response body or not.
send_request
Sends an outbound HTTP request.
set_accepted
Records a decision indicating that the plugin wants to accept a request.
set_decision
Records the decision value the plugin wants to return.
set_param_value
Set a named value in the request context’s params.
set_remote_state
Set a named value in Redis.
set_remote_ttl
Sets an expiration on a named value in Redis.
set_restricted
Records a decision indicating that the plugin wants to restrict a request.
set_tags
Records the tags the plugin wants to associate with its decision.

Type Aliases§

Breaker
A Breaker contains the values needed to implement a circuit-breaker pattern within a plugin.
Error
Generic error
Rate
A Rate contains the values needed to implement a rate-limiter pattern within a plugin.
Request
An HTTP request combines a head consisting of a Method, Uri, and headers with a BodyChunk, which provides access to the first chunk of a request body.
Response
An HTTP response combines a head consisting of a StatusCode and headers with a BodyChunk, which provides access to the first chunk of a response body.
Result
Generic result

Attribute Macros§

bulwark_plugin
The bulwark_plugin attribute generates default implementations for all handler traits in a module and produces friendly errors for common mistakes.